package org.springblade.pm.wrappper;

import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.pm.entity.Contract;
import org.springblade.pm.entity.Problem;
import org.springblade.pm.vo.ContractVo;
import org.springblade.pm.vo.ProblemVo;
import org.springblade.system.feign.IDictClient;

import java.util.ArrayList;
import java.util.List;

public class ProblemWrapper extends BaseEntityWrapper<Problem,ProblemVo> {
	static IDictClient dictClient;
	static {
		dictClient = SpringUtil.getBean(IDictClient.class);
	}
	public static ProblemWrapper build() {
		return new ProblemWrapper();
	}

	@Override
	public ProblemVo entityVO(Problem entity) {
		ProblemVo problemVo = BeanUtil.copy(entity, ProblemVo.class);
		R<String> problemTypeName = dictClient.getValue("problem_type", entity.getProblemType());
		if (problemTypeName.isSuccess()) {
			problemVo.setProblemTypeName(problemTypeName.getData());
		}
		return problemVo;
	}

	public List<ProblemVo> entityVoList(List<Problem> list) {
		List<ProblemVo> problemVOList = new ArrayList<>();
		for (Problem problem : list) {
			problemVOList.add(entityVO(problem));
		}
		return problemVOList;
	}
}
